<template>
  <div>
    <div class="cartwarning" v-if="getdate[0] < getdate[1] ? 'isShow' : ''">
      <van-notice-bar mode="null">
        <van-icon name="warning-o" />
        所选商品库存不足，只能购买：
        <span>{{ getdate[0] }}</span> 个商品。</van-notice-bar
      >
    </div>
    <div class="getcarttime" v-else>
      <van-cell title="选择送达时间" :value="date" @click="show = true" />
      <van-calendar v-model="show" @confirm="onConfirm" />
      <van-icon name="arrow" />
    </div>
  </div>
</template>

<script>
export default {
  props: {
    getdate: {
      type: Array,
      require: true,
    },
  },
  data() {
    return {
      date: "",
      show: false,
      // 以上组件的内容
    };
  },
  methods: {
    onConfirm(date) {
      this.show = false;
      this.date = this.formatDate(date);
    },
    formatDate(date) {
      return `2022/${date.getMonth() + 1}/${date.getDate()}`;
    },
  },
};
</script>

<style src="../assets/css/payCart.css" scoped>
</style>